package com.heiye.count.biz.controller;

import com.heiye.count.api.dto.FindQuizCountsByIdReqDTO;
import com.heiye.count.api.dto.FindQuizCountsByIdRspDTO;
import com.heiye.count.api.dto.FindQuizCountsByIdsReqDTO;
import com.heiye.count.api.dto.UpdateQuizCommentCountReqDTO;
import com.heiye.count.biz.service.QuizCountService;
import com.heiye.framework.biz.operationlog.aspect.ApiOperationLog;
import com.heiye.framework.common.response.Response;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: heiye
 * @date: 2025/07/14 下午12:09
 * @version: v1.0.0
 * @description: 问题维度计数
 */
@RestController
@RequestMapping("/count")
@Slf4j
public class QuizCountController {

    @Resource
    private QuizCountService quizCountService;

    @PostMapping(value = "/quizzes/data")
    @ApiOperationLog(description = "批量查询问题计数数据")
    public Response<List<FindQuizCountsByIdRspDTO>> findQuizzesCountData(@Validated @RequestBody FindQuizCountsByIdsReqDTO findQuizCountsByIdsReqDTO) {
        return quizCountService.findQuizzesCountData(findQuizCountsByIdsReqDTO);
    }

    // ===================================== 对其他服务提供的接口 =====================================

    @PostMapping(value = "/quiz/data")
    @ApiOperationLog(description = "查询问题计数数据")
    public Response<FindQuizCountsByIdRspDTO> findQuizCountData(@Validated @RequestBody FindQuizCountsByIdReqDTO findQuizCountsByIdReqDTO) {
        return quizCountService.findQuizCountData(findQuizCountsByIdReqDTO);
    }

    @PostMapping(value = "/quiz/comment/count")
    @ApiOperationLog(description = "更新问题评论计数数据")
    public Response<?> updateQuizCommentCountData(@RequestBody UpdateQuizCommentCountReqDTO updateQuizCommentCountReqDTO) {
        return quizCountService.updateQuizCommentCountData(updateQuizCommentCountReqDTO);
    }
}
